import { ref } from 'vue'; // ✅ 添加此行导入 ref
import { defineStore } from 'pinia';

//定义store
export const useMemberStore = defineStore('member', () => {
  //会员信息
  const peofile = ref();

  //保存会员信息，登录时使用
  const setprofile = (val:any) => {
    peofile.value = val;
  }

  //清理会员信息，退出登录时使用
  const clearprofile = () => {
    peofile.value = undefined;
  }

  //记得return

  return {
    peofile,
    setprofile,
    clearprofile
  }
}, 

//TODO:持久化
{
  persist:{
    storage:{
      getItem: (key) => {
        return uni.getStorageSync(key);
      },
      setItem: (key, value) => {
        uni.setStorageSync(key, value);
      }
    }
  }
}
)